<template>
    <div>
        <s-Home>
            <div>
                <Input v-model="value" icon="ios-search" placeholder="请输入..." class="inputsearch"></Input>
            </div>
            <Table :columns="columns1" :data="data1"></Table>
            <div class="page">
                <Page :total="total" show-elevator :page-size="pageSize" @on-change="pageChange" show-total></Page>
            </div>
        </s-Home>
    </div>
</template>

<script>
    import api from '../network/api/inventory.js'
    export default {
        name: 'AllProduct',

        data() {
            return {
                value: '',
                total: 0,
                pageSize: 14,
                columns1: [
                    {
                        title: '序列',
                        key: 'id'
                    },
                    {
                        title: '货物编号',
                        key: 'goods_num'
                    },
                    {
                        title: '货物名称',
                        key: 'goods_name'
                    },
                    {
                        title: '货物类型',
                        key: 'category'
                    },
                    {
                        title: '库存数量（件）',
                        key: 'quantity'
                    },
                    {
                        title: '进货价格（元）',
                        key: 'purchase_price'
                    },
                    {
                        title: '进货厂商',
                        key: 'purchase_supplier'
                    }, {
                        title: '进货负责人',
                        key: 'purchase_responsible'
                    }
                ],
                data1: [],
                data2: [],
            };
        },

        mounted() {
           
        },

        methods: {
            async getPro() {
                let res = await api.getInventory();
                this.data2 = res.data;
                this.data1 = this.data2.slice(0, 14);
                this.total = res.data.length;
            },
            //改变页码回调
            pageChange(index) {
                this.data1 = this.data2.slice((index - 1) * 14, (index - 1) * 14 + 14)
                console.log('当前页码：' + index);
            },


        },
        created () {
            this.getPro();
        }
    };
</script>

<style scoped>
    .page {
        text-align: center;
        margin-top: 15px;
    }

    .inputsearch {
        width: 500px;
        margin-bottom: 10px;
    }
</style>